package com.ljw.punishment.rulesengine;

import org.jeasy.rules.api.RulesEngineParameters;
import org.jeasy.rules.core.AbstractRulesEngine;
import org.jeasy.rules.core.DefaultRulesEngine;
import org.jeasy.rules.core.InferenceRulesEngine;

/**
 * @author lijunwei
 * @date 2025/5/21
 */
public class RuleEngineSelector {
    private RuleEngineSelector() {
    }

    public static AbstractRulesEngine select(int engineTypeCode, RulesEngineParameters rulesEngineParameters) {
        EngineTypeEnum engineType = EngineTypeEnum.getEngineTypeByCode(engineTypeCode);
        if (null == engineType) {
            new Exception("不存在的规则引擎类型");
        }

        AbstractRulesEngine rulesEngine;
        if (engineType == EngineTypeEnum.DEFAULT_RULE_ENGINE) {
            rulesEngine = new DefaultRulesEngine(rulesEngineParameters);
        } else {
            rulesEngine = new InferenceRulesEngine(rulesEngineParameters);
        }
        return rulesEngine;
    }
}